package com.rongshu.utils;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

import java.lang.ref.WeakReference;

/**
 * created by zhengweis on 2018/11/13.
 * description：
 */
public class GlideUtils {
    public static void loadImageView(Context context, ImageView view, String url, int defaultImg, int errorImg) {
        RequestOptions options = new RequestOptions()
                .error(errorImg)
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE)
                .centerCrop()
                .placeholder(defaultImg);
        Glide.with(context).load(url).apply(options).into(view);
    }

    public static void loadImageView(Context context, ImageView view, String url) {
        RequestOptions options = new RequestOptions()
                .diskCacheStrategy(DiskCacheStrategy.RESOURCE);
        Glide.with(context).load(url).apply(options).into(view);
    }
}
